home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / trim_lib / trim_err.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-27  |  2.4 KB  |  52 lines

  1. /******************************************************************************
  2. * Trim_err.c - handler for all trim library fatal errors.              *
  3. *******************************************************************************
  4. * Written by Gershon Elber, October 94.                          *
  5. ******************************************************************************/
  6.  
  7. #include "trim_loc.h"
  8.  
  9. typedef struct TrimErrorStruct {
  10.     TrimFatalErrorType ErrorNum;
  11.     char *ErrorDesc;
  12. } TrimErrorStruct;
  13.  
  14. static TrimErrorStruct ErrMsgs[] =
  15. {
  16.     { TRIM_ERR_TRIM_CRV_E2,    "Trimming curve must have E2 point type." },
  17.  
  18.     { TRIM_ERR_BZR_BSP_EXPECT,    "Bezier or Bspline representation expected." },
  19.     { TRIM_ERR_DIR_NOT_CONST_UV,"Dir is not one of CONST_U/V_DIR." },
  20.     { TRIM_ERR_ODD_NUM_OF_INTER,"Odd # of intersections with trimming crvs." },
  21.  
  22.     { TRIM_ERR_UNDEFINE_ERR,    NULL }
  23. };
  24.  
  25. /*****************************************************************************
  26. * DESCRIPTION:                                                               M
  27. * Returns a string describing a the given error. Errors can be raised by     M
  28. * any member of this trim library as well as other users. Raised error will  M
  29. * cause an invokation of TrimFatalError function which decides how to handle M
  30. * this error. TrimFatalError can for example, invoke this routine with the   M
  31. * error type, print the appropriate message and quit the program.            M
  32. *                                                                            *
  33. * PARAMETERS:                                                                M
  34. *   ErrorNum:   Type of the error that was raised.                           M
  35. *                                                                            *
  36. * RETURN VALUE:                                                              M
  37. *   char *:     A string describing the error type.                          M
  38. *                                                                            *
  39. * KEYWORDS:                                                                  M
  40. *   TrimDescribeError, error handling                                        M
  41. *****************************************************************************/
  42. char *TrimDescribeError(TrimFatalErrorType ErrorNum)
  43. {
  44.     int i = 0;
  45.  
  46.     for ( ; ErrMsgs[i].ErrorDesc != NULL; i++)
  47.     if (ErrorNum == ErrMsgs[i].ErrorNum)
  48.         return ErrMsgs[i].ErrorDesc;
  49.  
  50.     return "Undefined error";
  51. }
  52.